// Local Includes
#include "stdafx.h"
#include "MyXBoxCont.h"

// SDL Includes

// System Includes

MyXBoxCont::MyXBoxCont( int iCont )
: _iCont(iCont)
{
}

MyXBoxCont::~MyXBoxCont()
{
}

bool 
MyXBoxCont::isActive()
{
    memset( &_xState, 0, sizeof(XINPUT_STATE) );
    DWORD res = XInputGetState(_iCont,&_xState);

    return res == ERROR_SUCCESS; 
}

const XINPUT_STATE& 
MyXBoxCont::xState()
{
    memset( &_xState, 0, sizeof(XINPUT_STATE) );
    DWORD res = XInputGetState(_iCont,&_xState);
    return _xState;
}
   
void 
MyXBoxCont::makeVibrate( int l, int r )
{
    XINPUT_VIBRATION xVib;
    memset( &xVib, 0, sizeof(XINPUT_VIBRATION) );

    xVib.wLeftMotorSpeed  = l;
    xVib.wRightMotorSpeed = r;

    XInputSetState(_iCont,&xVib);
}